﻿using System.Collections.Generic;

static class TextureImporterUtility
{
    public static TextureImporterType GetTextureImporterType(string path)
    {
        TextureImporterType type;
        if (IsBig(path))
            type = TextureImporterType.Big;
        else if (IsSmall(path))
            type = TextureImporterType.Small;
        else if (IsEffect(path))
            type = TextureImporterType.Effect;
        else if (IsAnimations(path))
            type = TextureImporterType.Animation;
        else
            type = TextureImporterType.None;
        return type;
    }

    public static bool IsFilter(string path)
    {
        if (string.IsNullOrEmpty(path)) return true;

        foreach (var exclude in EXCLUDES)
            if (path.Contains(exclude)) return true;

        bool bRet = false;
        foreach (var include in INCLUDES)
            bRet |= path.Contains(include);

        return !bRet;

    }

    static bool IsSmall(string path)
    {
        if (string.IsNullOrEmpty(path)) return false;
        foreach (var small in SMALLS)
            if (path.Contains(small)) return true;
        return false;
    }

    static bool IsBig(string path)
    {
        if (string.IsNullOrEmpty(path)) return false;
        foreach (var big in BIGS)
            if (path.Contains(big)) return true;
        return false;
    }

    static bool IsEffect(string path)
    {
        if (string.IsNullOrEmpty(path)) return false;
        foreach (var effect in EFFECTS)
            if (path.Contains(effect)) return true;
        return false;
    }

    static bool IsAnimations(string path)
    {
        if (string.IsNullOrEmpty(path)) return false;
        foreach (var animation in ANIMATIONS)
            if (path.Contains(animation)) return true;
        return false;
    }


    static readonly List<string> INCLUDES = new()
    {
        "Assets/Game/Repository/ResEffects",
        "Assets/Game/Repository/Animations",

        // old ui directory
        "Assets/Game/Repository/UITextures",
        "Assets/Game/Repository/SpriteAtlas_Texture",

        // new ui directory
        "Assets/Game/Repository/Formation/Big",
        "Assets/Game/Repository/Formation/Small",
    };

    static readonly List<string> EXCLUDES = new()
    {
        "Assets/Game/Repository/ResEffects/BoxEffect"
    };

    static readonly List<string> BIGS = new()
    {
        // old
        "Assets/Game/Repository/UITextures",
        // new
        "Assets/Game/Repository/Formation/Big",
    };

    static readonly List<string> SMALLS = new()
    {
        // old
        "Assets/Game/Repository/SpriteAtlas_Texture",
        // new
        "Assets/Game/Repository/Formation/Small",
    };

    static readonly List<string> EFFECTS = new()
    {
       "Assets/Game/Repository/ResEffects"
    };

    static readonly List<string> ANIMATIONS = new()
    {
       "Assets/Game/Repository/Animations"
    };
}
